package com.rich.order.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rich.common.result.ResultData;
import com.rich.common.entity.TbOrder;
import com.rich.order.mapper.OrderMapper;
import com.rich.order.service.OrderService;
import com.rich.order.vo.OrderListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:fei
 * @Date:2021/8/16
 */
@Slf4j
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public ResultData orderList(OrderListVo orderListVo) {
        PageHelper.startPage(orderListVo.getPage(), orderListVo.getLimit());
        List<TbOrder> list =  orderMapper.orderList(orderListVo);
        PageInfo pageInfo = new PageInfo(list);
        return new  ResultData(pageInfo.getList(),pageInfo.getTotal());
    }

    @Override
    public void delOrder(String id) {
        orderMapper.delOrder(id);
    }

    @Override
    public void deletes(String[] ids) {
        for (String id : ids) {
            orderMapper.delOrder(id);
        }
    }

    @Override
    public List<TbOrder> findAll() {
        return orderMapper.findAll();
    }


}
